package com.ruoyi.web.controller.base;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.BusPsBasEquipment;
import com.ruoyi.base.service.IBusPsBasEquipmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 在线-设备Controller
 * 
 * @author maliang
 * @date 2025-09-22
 */
@RestController
@RequestMapping("/base/equipment")
public class BusPsBasEquipmentController extends BaseController
{
    @Autowired
    private IBusPsBasEquipmentService busPsBasEquipmentService;

    /**
     * 查询在线-设备列表
     */
    //@PreAuthorize("@ss.hasPermi('base:equipment:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusPsBasEquipment busPsBasEquipment)
    {
        startPage();
        List<BusPsBasEquipment> list = busPsBasEquipmentService.selectBusPsBasEquipmentList(busPsBasEquipment);
        return getDataTable(list);
    }

    /**
     * 导出在线-设备列表
     */
    //@PreAuthorize("@ss.hasPermi('base:equipment:export')")
    @Log(title = "在线-设备", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusPsBasEquipment busPsBasEquipment)
    {
        List<BusPsBasEquipment> list = busPsBasEquipmentService.selectBusPsBasEquipmentList(busPsBasEquipment);
        ExcelUtil<BusPsBasEquipment> util = new ExcelUtil<BusPsBasEquipment>(BusPsBasEquipment.class);
        util.exportExcel(response, list, "在线-设备数据");
    }

    /**
     * 获取在线-设备详细信息
     */
    //@PreAuthorize("@ss.hasPermi('base:equipment:query')")
    @GetMapping(value = "/{datagathercode}")
    public AjaxResult getInfo(@PathVariable("datagathercode") String datagathercode)
    {
        return success(busPsBasEquipmentService.selectBusPsBasEquipmentByDatagathercode(datagathercode));
    }

    /**
     * 新增在线-设备
     */
    //@PreAuthorize("@ss.hasPermi('base:equipment:add')")
    @Log(title = "在线-设备", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BusPsBasEquipment busPsBasEquipment)
    {
        return toAjax(busPsBasEquipmentService.insertBusPsBasEquipment(busPsBasEquipment));
    }

    /**
     * 修改在线-设备
     */
    //@PreAuthorize("@ss.hasPermi('base:equipment:edit')")
    @Log(title = "在线-设备", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BusPsBasEquipment busPsBasEquipment)
    {
        return toAjax(busPsBasEquipmentService.updateBusPsBasEquipment(busPsBasEquipment));
    }

    /**
     * 删除在线-设备
     */
    //@PreAuthorize("@ss.hasPermi('base:equipment:remove')")
    @Log(title = "在线-设备", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{datagathercodes}")
    public AjaxResult remove(@PathVariable String[] datagathercodes)
    {
        return toAjax(busPsBasEquipmentService.deleteBusPsBasEquipmentByDatagathercodes(datagathercodes));
    }
}
